<?php
class Exts_Db_Table_AuditableModel extends Exts_Db_Table_Abstract {
	
	public function findById($id){
		return $this->fetchRow($this->select()->where("$this->_primary = ?", $id));
	}
	
	public function save ($bind) {
		$row = $this->findById($bind [$this->_primary]);
		if (!$row) {
			$row = $this->createRow();
			$bind['creation_date'] =date("Y-m-d");
			
			$bind['creation_user'] =$this->getUser()->user_id;  
		}
		$bind['last_modification_date'] =date("Y-m-d");
		$bind['modification_user'] =$this->getUser()->user_id;
		 
		$row->setFromArray($bind);
		$row->save();
		return $row;
	}
}